package doantotnghiep.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.NamedNativeQuery;

@Entity
@NamedNativeQuery(name="getAllProvider", query="call GetAllProvider();" ,resultClass = Provider.class)
@Table(name ="NhaCungCap")
public class Provider {
	private int id;
	private String fullName;
	private String address;
	private String telNumber;
	private String email;
	private int status;
	
	@Id
	@GeneratedValue
	@Column(name ="MaCT")
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	@Column(name ="TenCT")
	public String getFullName() {
		return fullName;
	}
	
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}
	
	@Column(name ="DiaChi")
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	@Column(name ="DienThoai")
	public String getTelNumber() {
		return telNumber;
	}
	
	public void setTelNumber(String telNumber) {
		this.telNumber = telNumber;
	}
	
	@Column(name ="Email")
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}	
	
    private Set<Medicament> medicaments = new HashSet<Medicament>();
    
    @OneToMany(mappedBy = "provider", fetch = FetchType.LAZY) 
	@Fetch(FetchMode.JOIN)
	public Set<Medicament> getMedicaments() {
		return medicaments;
	}

	public void setMedicaments(Set<Medicament> medicaments) {
		this.medicaments = medicaments;
	} 
	
	@Column(name ="TrangThai")
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
}
